require('dotenv').config();
const express = require('express');
const cors = require('cors');

const app = express();
const port = process.env.PORT || 3000;


// 配置静态文件服务
//app.use(express.static('public'));
// Middleware
app.use(cors());
app.use(express.json());

// Routes
const userRoutes = require('./routes/users');
const itemRoutes = require('./routes/items');
// 添加购物车和订单路由
const cartRoutes = require('./routes/cart');
const orderRoutes = require('./routes/orders');
// 添加图片上传路由
const imageRoutes = require('./routes/images');
app.use('/images', imageRoutes);

app.use('/users', userRoutes);
app.use('/items', itemRoutes);

app.use('/cart', cartRoutes);
app.use('/orders', orderRoutes);

app.listen(port, () => {
  console.log(`Server is running on http://localhost:${port}`);
});